package com.link.base.base.report.controller;

import com.link.base.base.activity.model.Activitys;
import com.link.base.base.report.model.*;
import com.link.base.base.report.model.ActivityReport;
import com.link.base.base.report.service.ActivityReportService;
import com.link.core.cllog.LCLogger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author daichenyu
 * @date 2019/03/05
 */
@Controller
@RequestMapping("/link/report")
public class ActivityReportController {
    @Resource
    private ActivityReportService activityReportService;

    /**
     * 活动根据‘活动类型’字段做汇总（状态为‘进行中’，‘已结束’）
     * @author daichenyu
     * @date 2019/03/05
     * @return
     */
    @RequestMapping(value = "/queryActivityByType", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> queryActivityByType() {
        Map<String,Object> result = new HashMap<>();
        try {
            List<ActivityReport> list = activityReportService.queryByType(new Activitys());
            result.put("success", true);
            result.put("rows", list);
        } catch (Exception e) {
            LCLogger.withException(e);
            result.put("success", false);
            result.put("message", e.getMessage());
        }
        return result;
    }
}
